home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
quartz
/
q1082.dms
/
q1082.adf
/
src.lzh
/
Fig
/
MenuStuff.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-18
|
2KB
|
119 lines
extern struct TextAttr StandardFont;
struct MetaMenu
{
struct MenuItem Item;
struct IntuiText Text;
};
STATIC struct MenuItem *LastItem;
VOID
ClearMenu(struct Menu *Menu)
{
struct MenuItem *Item,*NextItem;
if(Item = Menu -> FirstItem)
{
NextItem = Item -> NextItem;
FreeMem(Item,sizeof(struct MetaMenu) + 10);
Item = NextItem;
}
FreeMem(Menu,sizeof(struct Menu));
}
struct Menu *
CreateMenu(UBYTE *Title)
{
struct Menu *Menu;
if(Menu = (struct Menu *)AllocMem(sizeof(struct Menu),MEMF_PUBLIC|MEMF_CLEAR))
{
Menu -> LeftEdge = 2;
Menu -> Flags = MENUENABLED;
Menu -> MenuName = Title;
Menu -> Width = strlen(Title) * 8 + 8;
}
return(Menu);
}
struct MenuItem *
AddItem(struct Menu *Menu,UBYTE *Text,UBYTE Command)
{
struct MetaMenu *Meta;
if(Meta = (struct MetaMenu *)AllocMem(sizeof(struct MetaMenu) + 10,MEMF_PUBLIC|MEMF_CLEAR))
{
LONG Width = strlen(Text);
if(LastItem)
{
LastItem -> NextItem = &Meta -> Item;
Meta -> Item . TopEdge = LastItem -> TopEdge + LastItem -> Height;
}
LastItem = &Meta -> Item;
if(Command)
Width += 4;
Meta -> Item . Width = (Width * 8) + 4;
Meta -> Item . Height = 10;
Meta -> Item . Flags = ITEMENABLED|HIGHCOMP|ITEMTEXT;
if(Command)
{
Meta -> Item . Flags |= COMMSEQ;
Meta -> Item . Width += 20;
}
Meta -> Item . ItemFill = &Meta -> Text;
Meta -> Item . Command = Command;
Meta -> Text . FrontPen = 0;
Meta -> Text . BackPen = 1;
Meta -> Text . DrawMode = JAM2;
Meta -> Text . LeftEdge = 2;
Meta -> Text . TopEdge = 1;
Meta -> Text . ITextFont = &StandardFont;
Meta -> Text . IText = Text;
if(Menu -> FirstItem)
{
struct MenuItem *Item;
LONG MaxWidth = 0;
Item = Menu -> FirstItem;
while(Item)
{
if(Item -> Width > MaxWidth)
MaxWidth = Item -> Width;
Item = Item -> NextItem;
}
Item = Menu -> FirstItem;
while(Item)
{
Item -> Width = MaxWidth;
Item = Item -> NextItem;
}
/* Menu -> Width = MaxWidth + 4;*/
}
else
Menu -> FirstItem = &Meta -> Item;
}
return(Meta);
}